//
//  IWRGB.m
//  PM2.5
//
//  Created by Mac on 15-9-7.
//  Copyright (c) 2015年 junmo. All rights reserved.
//

#import "IWRGB.h"
#import "IWAqi.h"
@implementation IWRGB


+(UIColor*)RGBWithAQI:(NSString*)AQI{
    
    
    if ([AQI integerValue]>0&&[AQI integerValue]<=50) {
       
        UIColor*rgb=[[UIColor alloc]initWithRed:66.0/255.0 green:206.0/255.0 blue:23.0/255.0 alpha:1.0];
        return rgb;
        
    }else if([AQI integerValue]>50&&[AQI integerValue]<=100){
        UIColor*rgb=[[UIColor alloc]initWithRed:239.0/255.0 green:220.0/255.0 blue:49.0/255.0 alpha:1.0];
        return rgb;
       
    }else if ([AQI integerValue]>100&&[AQI integerValue]<=150){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:170.0/255.0 blue:0.0/255.0 alpha:1.0];
        return rgb;
    }else if ([AQI integerValue]>150&&[AQI integerValue]<=200){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:64.0/255.0 blue:26.0/255.0 alpha:1.0];
        return rgb;
    }else if ([AQI integerValue]>200&&[AQI integerValue]<=300){
        UIColor*rgb=[[UIColor alloc]initWithRed:210.0/255.0 green:0.0/255.0 blue:63.0/255.0 alpha:1.0];
        return rgb;
       
    }else if ([AQI integerValue]>300){
        UIColor*rgb=[[UIColor alloc]initWithRed:156.0/255.0 green:10.0/255.0 blue:78.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([AQI integerValue]==0){
        
        UIColor*rgb=[UIColor lightGrayColor];
        return rgb;
        
    }

    
    return nil;
    
}
+(NSString*)RGBWithAQIlevel:(NSString*)AQI{
    
    if ([AQI integerValue]>0&&[AQI integerValue]<=50) {
        
//        UIColor*rgb=[[UIColor alloc]initWithRed:66.0/255.0 green:206.0/255.0 blue:23.0/255.0 alpha:1.0];
        return @"优";
        
    }else if([AQI integerValue]>50&&[AQI integerValue]<=100){
//        UIColor*rgb=[[UIColor alloc]initWithRed:239.0/255.0 green:220.0/255.0 blue:49.0/255.0 alpha:1.0];
        return @"良";
        
    }else if ([AQI integerValue]>100&&[AQI integerValue]<=150){
        
//        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:170.0/255.0 blue:0.0/255.0 alpha:1.0];
        return @"轻度";
    }else if ([AQI integerValue]>150&&[AQI integerValue]<=200){
        
//        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:64.0/255.0 blue:26.0/255.0 alpha:1.0];
        return @"中度";
    }else if ([AQI integerValue]>200&&[AQI integerValue]<=300){
//        UIColor*rgb=[[UIColor alloc]initWithRed:210.0/255.0 green:0.0/255.0 blue:63.0/255.0 alpha:1.0];
        return @"重度";
        
    }else if ([AQI integerValue]>300){
//        UIColor*rgb=[[UIColor alloc]initWithRed:156.0/255.0 green:10.0/255.0 blue:78.0/255.0 alpha:1.0];
        return @"严重";
        
    }else if ([AQI integerValue]==0){
        
//        UIColor*rgb=[UIColor lightGrayColor];
        return @"无";
        
    }
    
    
    return nil;
    
}

+(UIColor*)RGBWithPM2_5:(NSString*)PM2_5{
    
    
    if ([PM2_5 integerValue]>0&&[PM2_5 integerValue]<=35) {
        
        UIColor*rgb=[[UIColor alloc]initWithRed:66.0/255.0 green:206.0/255.0 blue:23.0/255.0 alpha:1.0];
        return rgb;
        
    }else if([PM2_5 integerValue]>35&&[PM2_5 integerValue]<=75){
        UIColor*rgb=[[UIColor alloc]initWithRed:239.0/255.0 green:220.0/255.0 blue:49.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([PM2_5 integerValue]>75&&[PM2_5 integerValue]<=115){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:170.0/255.0 blue:0.0/255.0 alpha:1.0];
        return rgb;
    }else if ([PM2_5 integerValue]>115&&[PM2_5 integerValue]<=150){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:64.0/255.0 blue:26.0/255.0 alpha:1.0];
        return rgb;
    }else if ([PM2_5 integerValue]>150&&[PM2_5 integerValue]<=250){
        UIColor*rgb=[[UIColor alloc]initWithRed:210.0/255.0 green:0.0/255.0 blue:63.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([PM2_5 integerValue]>250){
        UIColor*rgb=[[UIColor alloc]initWithRed:156.0/255.0 green:10.0/255.0 blue:78.0/255.0 alpha:1.0];
        return rgb;
        
        
    }
    
    
    return nil;

    
    
}

+(UIColor*)RGBWithPM10:(NSString*)PM10{
    
    if ([PM10 integerValue]>0&&[PM10 integerValue]<=50) {
        
        UIColor*rgb=[[UIColor alloc]initWithRed:66.0/255.0 green:206.0/255.0 blue:23.0/255.0 alpha:1.0];
        return rgb;
        
    }else if([PM10 integerValue]>50&&[PM10 integerValue]<=150){
        UIColor*rgb=[[UIColor alloc]initWithRed:239.0/255.0 green:220.0/255.0 blue:49.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([PM10 integerValue]>150&&[PM10 integerValue]<=250){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:170.0/255.0 blue:0.0/255.0 alpha:1.0];
        return rgb;
    }else if ([PM10 integerValue]>250&&[PM10 integerValue]<=350){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:64.0/255.0 blue:26.0/255.0 alpha:1.0];
        return rgb;
    }else if ([PM10 integerValue]>350&&[PM10 integerValue]<=420){
        UIColor*rgb=[[UIColor alloc]initWithRed:210.0/255.0 green:0.0/255.0 blue:63.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([PM10 integerValue]>420){
        UIColor*rgb=[[UIColor alloc]initWithRed:156.0/255.0 green:10.0/255.0 blue:78.0/255.0 alpha:1.0];
        return rgb;
        
        
    }
    
    
    return nil;

    
    
}

+(UIColor*)RGBWithO3:(NSString*)O3{
    
    if ([O3 integerValue]>0&&[O3 integerValue]<=100) {
        
        UIColor*rgb=[[UIColor alloc]initWithRed:66.0/255.0 green:206.0/255.0 blue:23.0/255.0 alpha:1.0];
        return rgb;
        
    }else if([O3 integerValue]>100&&[O3 integerValue]<=160){
        UIColor*rgb=[[UIColor alloc]initWithRed:239.0/255.0 green:220.0/255.0 blue:49.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([O3 integerValue]>160&&[O3 integerValue]<=215){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:170.0/255.0 blue:0.0/255.0 alpha:1.0];
        return rgb;
    }else if ([O3 integerValue]>215&&[O3 integerValue]<=265){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:64.0/255.0 blue:26.0/255.0 alpha:1.0];
        return rgb;
    }else if ([O3 integerValue]>265&&[O3 integerValue]<=800){
        UIColor*rgb=[[UIColor alloc]initWithRed:210.0/255.0 green:0.0/255.0 blue:63.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([O3 integerValue]>800){
        UIColor*rgb=[[UIColor alloc]initWithRed:156.0/255.0 green:10.0/255.0 blue:78.0/255.0 alpha:1.0];
        return rgb;
        
        
    }
    
    
    return nil;

    
    
    
}
+(UIColor*)RGBWithSO2:(NSString*)SO2{
    
    
    if ([SO2 integerValue]>0&&[SO2 integerValue]<=50) {
        
        UIColor*rgb=[[UIColor alloc]initWithRed:66.0/255.0 green:206.0/255.0 blue:23.0/255.0 alpha:1.0];
        return rgb;
        
    }else if([SO2 integerValue]>50&&[SO2 integerValue]<=150){
        UIColor*rgb=[[UIColor alloc]initWithRed:239.0/255.0 green:220.0/255.0 blue:49.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([SO2 integerValue]>150&&[SO2 integerValue]<=475){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:170.0/255.0 blue:0.0/255.0 alpha:1.0];
        return rgb;
    }else if ([SO2 integerValue]>475&&[SO2 integerValue]<=800){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:64.0/255.0 blue:26.0/255.0 alpha:1.0];
        return rgb;
    }else if ([SO2 integerValue]>800&&[SO2 integerValue]<=1600){
        UIColor*rgb=[[UIColor alloc]initWithRed:210.0/255.0 green:0.0/255.0 blue:63.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([SO2 integerValue]>1600){
        UIColor*rgb=[[UIColor alloc]initWithRed:156.0/255.0 green:10.0/255.0 blue:78.0/255.0 alpha:1.0];
        return rgb;
        
        
    }
    
    
    return nil;
    
}
+(UIColor*)RGBWithNO2:(NSString*)NO2{
    
    
    if ([NO2 integerValue]>0&&[NO2 integerValue]<=40) {
        
        UIColor*rgb=[[UIColor alloc]initWithRed:66.0/255.0 green:206.0/255.0 blue:23.0/255.0 alpha:1.0];
        return rgb;
        
    }else if([NO2 integerValue]>40&&[NO2 integerValue]<=80){
        UIColor*rgb=[[UIColor alloc]initWithRed:239.0/255.0 green:220.0/255.0 blue:49.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([NO2 integerValue]>80&&[NO2 integerValue]<=180){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:170.0/255.0 blue:0.0/255.0 alpha:1.0];
        return rgb;
    }else if ([NO2 integerValue]>180&&[NO2 integerValue]<=280){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:64.0/255.0 blue:26.0/255.0 alpha:1.0];
        return rgb;
    }else if ([NO2 integerValue]>280&&[NO2 integerValue]<=565){
        UIColor*rgb=[[UIColor alloc]initWithRed:210.0/255.0 green:0.0/255.0 blue:63.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([NO2 integerValue]>565){
        UIColor*rgb=[[UIColor alloc]initWithRed:156.0/255.0 green:10.0/255.0 blue:78.0/255.0 alpha:1.0];
        return rgb;
        
        
    }
    
    
    return nil;

    
}
+(UIColor*)RGBWithCO:(NSString*)CO{
    
    if ([CO floatValue]>0.0&&[CO floatValue]<=2.0) {
        
        UIColor*rgb=[[UIColor alloc]initWithRed:66.0/255.0 green:206.0/255.0 blue:23.0/255.0 alpha:1.0];
        return rgb;
        
    }else if([CO floatValue]>2.0&&[CO floatValue]<=4.0){
        UIColor*rgb=[[UIColor alloc]initWithRed:239.0/255.0 green:220.0/255.0 blue:49.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([CO floatValue]>4.0&&[CO floatValue]<=14.0){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:170.0/255.0 blue:0.0/255.0 alpha:1.0];
        return rgb;
    }else if ([CO integerValue]>14.0&&[CO integerValue]<=24.0){
        
        UIColor*rgb=[[UIColor alloc]initWithRed:255.0/255.0 green:64.0/255.0 blue:26.0/255.0 alpha:1.0];
        return rgb;
    }else if ([CO floatValue]>24.0&&[CO floatValue]<=36.0){
        UIColor*rgb=[[UIColor alloc]initWithRed:210.0/255.0 green:0.0/255.0 blue:63.0/255.0 alpha:1.0];
        return rgb;
        
    }else if ([CO integerValue]>36.0){
        UIColor*rgb=[[UIColor alloc]initWithRed:156.0/255.0 green:10.0/255.0 blue:78.0/255.0 alpha:1.0];
        return rgb;
        
        
    }
    
    
    return nil;

    
    
}

+(UIColor*)RGBWithWURangAqi:(IWAqi*)wurangAqi{
    
    double a=[wurangAqi.aqi floatValue];
    
    if (a<=50&&a>0) {
        
        UIColor*rgb=[UIColor colorWithRed:83.0/255.0 green:126.0/255.0 blue:168.0/255.0 alpha:0.5];
        
        return rgb;
    }else if (a>50&&a<=100){
        
        UIColor*rgb=[UIColor colorWithRed:83.0/255.0 green:126.0/255.0 blue:168.0/255.0 alpha:0.5];
        
        return rgb;
    }else if (a>100&&a<=150){
        
//        UIColor*rgb=[UIColor colorWithRed:83.0/255.0 green:126.0/255.0 blue:168.0/255.0 alpha:0.5];
        UIColor*rgb=[UIColor colorWithRed:0.0/255.0 green:28.0/255.0 blue:60.0/255.0 alpha:0.5];

        
        return rgb;
    }else if (a>150&&a<=200){
        
        UIColor*rgb=[UIColor colorWithRed:166.0/255.0 green:168.0/255.0 blue:163.0/255.0 alpha:0.5];
        
        return rgb;
    }else if (a>200&&a<=300){
        
        UIColor*rgb=[UIColor colorWithRed:83.0/255.0 green:126.0/255.0 blue:168.0/255.0 alpha:0.5];
        
        return rgb;
    }else if(a>300){
        
        UIColor*rgb=[UIColor colorWithRed:83.0/255.0 green:126.0/255.0 blue:168.0/255.0 alpha:0.5];
        
        return rgb;
        
    }else{
        return nil;
    }

    
    
    
}
+(UIColor*)RGBWithWURangBottomAqi:(IWAqi*)bottomAqi{
    
    double a=[bottomAqi.aqi floatValue];
    
    if (a<=50&&a>0) {
        
        UIColor*rgb=[UIColor colorWithRed:100.0/255.0 green:156.0/255.0 blue:214.0/255.0 alpha:1.0];
        
        return rgb;
    }else if (a>50&&a<=100){
        
        UIColor*rgb=[UIColor colorWithRed:100.0/255.0 green:156.0/255.0 blue:214.0/255.0 alpha:1.0];
        
        return rgb;
    }else if (a>100&&a<=150){
        
        //        UIColor*rgb=[UIColor colorWithRed:83.0/255.0 green:126.0/255.0 blue:168.0/255.0 alpha:0.5];
        UIColor*rgb=[UIColor colorWithRed:100.0/255.0 green:156.0/255.0 blue:214.0/255.0 alpha:1.0];
        
        
        return rgb;
    }else if (a>150&&a<=200){
        
        UIColor*rgb=[UIColor whiteColor];
        return rgb;
    }else if (a>200&&a<=300){
        
        UIColor*rgb=[UIColor colorWithRed:100.0/255.0 green:156.0/255.0 blue:214.0/255.0 alpha:1.0];
        
        return rgb;
    }else if(a>300){
        
        UIColor*rgb=[UIColor colorWithRed:100.0/255.0 green:156.0/255.0 blue:214.0/255.0 alpha:1.0];
        
        return rgb;
        
    }else{
        return nil;
    }
    

    
}


@end
